<%
layout("/layouts/platform.html"){
%>
<%DIRECTIVE DYNAMIC;%>
<style type="text/css">
/* 图片上传样式 */
.weui_uploader_input {
	position: absolute;
	z-index: 2;
	top: 30px;
	left: 0;
	width: 100%;
	height: 100%;
	opacity: 0;
	-webkit-tap-highlight-color: rgba(0, 0, 0, 0)
}

.weui_uploader_input_wrp {
	float: left;
	position: relative;
	margin-left: 50px;
	width: 70%;
	height: 110px;
	border: 1px solid #d9d9d9
}

.weui_uploader_input_wrp:after, .weui_uploader_input_wrp:before {
	content: " ";
	position: absolute;
	top: 50%;
	left: 50%;
	-webkit-transform: translate(-50%, -50%);
	transform: translate(-50%, -50%);
	background-color: #d9d9d9
}

.weui_uploader_input_wrp:before {
	width: 2px;
	height: 39.5px
}

.weui_uploader_input_wrp:after {
	width: 39.5px;
	height: 2px
}

.weui_uploader_input_wrp:active {
	border-color: #999
}

.weui_uploader_input_wrp:active:after, .weui_uploader_input_wrp:active:before
	{
	background-color: #999
}
</style>
<form id="companyAddForm" role="form" class="form-horizontal parsley-form" data-parsley-validate action="${base}/platform/student/toTwoEditDo" method="post">
<header class="header navbar bg-white shadow">
    <div class="btn-group tool-button">
        <a class="btn btn-default navbar-btn" href="${base}/platform/student/toTwo" data-pjax><i class="ti-angle-left" id="goback"></i> 返回</a>
    </div>
    <div class="pull-right">
    	<div class="btn-group tool-button">
    	 	<button  class="btn btn-default navbar-btn" onclick="submitForm();">提 交</button>
        </div>
   </div>
</header>

<div class="content-wrap">
	<div class="wrapper" style="min-height:500px;height: 100%;">
		<div class="box-tab">
			<ul class="nav nav-tabs">
				<li class="active">
          			<a href="#base_info" data-toggle="tab">入学录入</a>
				</li>
				<li>
                	<a href="#fujian" data-toggle="tab">附件</a>
                </li>
           	</ul>
			<div class="tab-content">
				<input type="hidden" name="id" value="${obj.student.id!}"/>
                <input type="hidden" name="customer_id" value="${obj.student.customer_id!}"/>
                <input type="hidden" name="enroll_id" value="${obj.student.enroll_id!}"/>
                
                <input type="hidden" name="progress" value="${obj.student.progress!}"/>
                <input type="hidden" name="enroll_state" value="${obj.student.enroll_state!}"/>
                <input type="hidden" name="school_id" value="${obj.student.school_id!}"/>
                
                
         		<div class="tab-pane fade active in" id="base_info">
         			<div class="row mb10">
         				<div class="form-group">
                            <label for="company_id" class="col-sm-2 control-label">档案归属</label>
	                 		<div class="col-sm-6">
                                <input type="text"  value="${obj.company.name!}" class="form-control" readonly="readonly"  placeholder="档案归属">
                                <input type="hidden"  value="${obj.company.id!}" name="company_id" >
                            </div>
                        </div>
                        <div class="form-group">
                        	<label for="enroll_time" class="col-sm-2 control-label">报名时间</label>
                            <div class="col-sm-6">
	                         	<input type="text" value="${@date.getDateInteger(obj.student.enroll_time!)}" readonly="readonly" class="form-control" />
	                         	<input type="hidden" id="enroll_time" name="enroll_time" value="${obj.student.enroll_time!}" />
	                		</div>
                        </div>
                        <div class="form-group">
                			<label for="school_id" class="col-sm-2 control-label">分配驾校</label>
	                 		<div class="col-sm-6">
	                 			<input type="text"  value="${obj.school.name!}" class="form-control" readonly="readonly" >
                            </div>
                      	</div>  
                      	<div class="form-group">  
                            <label for="driving_type" class="col-sm-2 control-label">驾考类型</label>
	                 		<div class="col-sm-6">
	                 			<input type="text"  value="<% if(obj.student.driving_type =='C1'){%>C1"<%}else{%>C2<%}%>" class="form-control" readonly="readonly" >
                            </div>
                        </div>
                     	<div class="form-group">
                            <label for="name" class="col-sm-2 control-label">名称</label>
                            <div class="col-sm-2">
                                <input type="text" id="name" value="${obj.student.name!}" class="form-control" name="name"   placeholder="名称" required="required"> 
                            </div>
                            
                            <label for="mobile" class="col-sm-2 control-label">电话</label>
                            <div class="col-sm-2">
                                <input type="text" id="mobile"  value="${obj.student.mobile!}" class="form-control" name="mobile"  placeholder="电话"   data-parsley-type="number" required="required">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="id_no" class="col-sm-2 control-label">身份证</label>
                            <div class="col-sm-2">
                                <input type="text" id="id_no" value="${obj.student.id_no!}" class="form-control" name="id_no"   placeholder="身份证" required="required">
                            </div>
                            
                            <label for="sex" class="col-sm-2 control-label">性别</label>
                            <div class="col-sm-2" style="margin-top: 5px">
                                 <input type="radio" required="required" name="sex"   value="0" <% if(obj.student.sex =='0'){%>checked="checked"<%}%> />男
                                 <input type="radio" required="required" name="sex"   value="1" <% if(obj.student.sex =='1'){%>checked="checked"<%}%> />女
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="birth" class="col-sm-2 control-label">出生日期</label>
	                   		<div class="col-sm-2">
	                      		<input type="text" size="16"  class="form-control" value="${obj.student.birth!}"   id="birth" name="birth" required="required">
	                		</div>
                        </div>
                        <div class="form-group">
                        	<label for="physical_results" class="col-sm-2 control-label">体检结果</label>
                            <div class="col-sm-2" style="margin-top: 5px">
                                 <input type="radio" required="required" name="physical_results"   value="0" <% if(obj.student.physical_results ==0){%>checked="checked"<%}%> />不合格
                                 <input type="radio" required="required" name="physical_results"   value="1" <% if(obj.student.physical_results ==1){%>checked="checked"<%}%> />合格
                            </div>
                        </div>
                      
               		</div>
         		</div>
         		
         		<div class="tab-pane fade" id="fujian">
         			<div class="row mb10">
                       	<div class="form-group">
                       		<label  class="col-sm-2 control-label">身份证</label>
	                       	<div style="clear:both;margin:10px 0;" id="photoDiv"  class="col-sm-10">
							</div>
	                       	<div  style="margin-left: 116px; margin-top: 8px;" >
								<div class="weui_uploader_input_wrp">
									<input id="one" type="file" class="weui_uploader_input accept="image/jpg,image/jpeg,image/png,image/gif" multiple="">
								</div>
							</div>
						</div>
						<div class="form-group">
                       		<label  class="col-sm-2 control-label">合同</label>
	                       	<div style="clear:both;margin:10px 0;" id="photoDiv2"  class="col-sm-10">
							</div>
	                       	<div  style="margin-left: 116px; margin-top: 8px;" >
								<div class="weui_uploader_input_wrp">
									<input id="one2" type="file" class="weui_uploader_input accept="image/jpg,image/jpeg,image/png,image/gif" multiple="">
								</div>
							</div>
						</div>
						
               		</div>
         		</div>
         	</div>
   		</div>
    </div>
</div>
</form>
<script language="JavaScript">

    $(document).ready(function () {
    	upload();
    	$.datetimepicker.setLocale('ch');
      	$('#birth').datetimepicker({
     		lang:'ch',
       		timepicker:false,
       		format:'Y-m-d',
       		formatDate:'Y-m-d'
     	});
    });
    
  	//图片上传
	var i = 0;
  	var j=0;
	function upload() {
		$('#one').change(
			function() {
				i++;
				var file = this.files[0];
				var r = new FileReader();
				r.readAsDataURL(file);
				$(r).load(function() {
					var html = '<div style="margin-left: 150px;">'+
								'<div style="float: left; width: 150px; height: 150px">'
								+ '<input type="hidden" name="url['+i+']" value="'+ this.result.replace(",", ".")+ '" />'
								+ '<img alt="" src="'+this.result +'" style="width: 150px; height: 150px" >'
								+ '<span style="position: relative; left: 123px; top:-145px; z-index: 10;">'
								+ '<img src="${base!}/assets/img/del.png" onclick="delold(this)" style="width:20px;height: 20px"/>'
								+ '</span></div></div>';
								$("#photoDiv").append(html);
				})
			}
		)
		$('#one2').change(
			function() {
				j++;
				var file = this.files[0];
				var r = new FileReader();
				r.readAsDataURL(file);
				$(r).load(function() {
					var html = '<div style="margin-left: 150px;">'+
								'<div style="float: left; width: 150px; height: 150px">'
								+ '<input type="hidden" name="ht['+j+']" value="'+ this.result.replace(",", ".")+ '" />'
								+ '<img alt="" src="'+this.result +'" style="width: 150px; height: 150px" >'
								+ '<span style="position: relative; left: 123px; top:-145px; z-index: 10;">'
								+ '<img src="${base!}/assets/img/del.png" onclick="delold(this)" style="width:20px;height: 20px"/>'
								+ '</span></div></div>';
								$("#photoDiv2").append(html);
				})
			}
		)
	}
	//删除原有图片
	function delold(obj) {
		jQuery(obj).parent().parent().remove();
	}
	
	function submitForm(){
		$.ajax({
			url : "${base}/platform/student/toTwoEditDo",
			data : $('#companyAddForm').serialize(),
			type : "post",
			async : false,
			dataType : "json",
			success : function(data) {
				if (data.code==0) {
					
                    Toast.success(data.msg);
                    setTimeout(function () {
                        $("#goback").trigger("click");
                    }, 1000);
                } else {
                    Toast.error(data.msg);
                }
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				wait = 0;
				toast("服务器异常");
				return false;
			}
		});
	}
</script>
<%}%>